import 'package:toggle_switch/toggle_switch.dart';

import 'package:flutter/material.dart';

void main() => runApp(KaterialApp());

class KaterialApp extends StatefulWidget {
  @override
  _KaterialApp createState() => _KaterialApp();
}

class _KaterialApp extends State<KaterialApp> {
  int currentIndex = 0;

  void _changePage(int index) {
    if (index != currentIndex) {
      setState(() {
        currentIndex = index;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: '整体标题',
      home: new Scaffold(
        backgroundColor: Color(0xFF3b3633),
        appBar: AppBar(
          title: Text('标题'),
          centerTitle: true,
          // 默认 false  true 为屏幕正中间 false 为除去图标之后的正中间
          backgroundColor: Color.fromRGBO(255, 79, 2, 1),
          // 背景色
          primary: true,
          //此应用栏是否显示在屏幕顶部  默认true true不在屏幕最顶部，false 和时间、电量、信号那些在一排
          // title: new Text('Welcome to Flut3232ter'),
          leading: IconButton(
            icon: const Icon(Icons.menu),
            tooltip: 'Next page',
            onPressed: () {},
          ),
          actions: <Widget>[
            IconButton(
              icon: const Icon(Icons.add_alert),
              tooltip: 'Show Snackbar',
              onPressed: () {},
            ),
            IconButton(
              icon: const Icon(Icons.navigate_next),
              tooltip: 'Next page',
              onPressed: () {},
            ),
          ],
        ),

        body: Center(
          child:

          ToggleSwitch(
            minWidth: 78.0,
            cornerRadius: 18.0,
            minHeight: 32.0,
            activeBorders: [Border.all(color: Color(0xFFECE9E1), width: 1.0)],
            activeBgColors: [
              [Color(0xFF1B1D1F)],
              [Color(0xFF1B1D1F)],
            ],
            activeFgColor: Color(0xFFFFD79E),
            inactiveBgColor: Color(0xFFECE9E1),
            inactiveFgColor: Color(0xFF1B1D1F),
            initialLabelIndex: 1,
            totalSwitches: 2,
            labels: ['展品', '展馆'],
            radiusStyle: true,
            onToggle: (index) {
              print('switched to: $index');
            },
          ),
        ),
      ),
    );
  }
}
